<!-- 内存进度条  -->
<template>
  <div id="memory-chart-main">
    <div class="mcm-left">
      <img class="mcm-icon" src="./img/icon-memory.png"></img>
    </div>
    <div class="mcm-right">
      <div class="mcmr-title">{{$t('memory_monitoring')}}</div>
      <div class="mcmr-process">
        <div class="progress-bar">
          <div class="progress" :style="{width:usedStr}">{{usedStr}}</div>
        </div>
      </div>
      <div class="mcmr-bottom">
        <div class="chart-label">
          <div class="legend" :style="{backgroundColor:'#b3934a'}"></div>
          <div class="legend-desc" > {{$t('memory_used_percent')}} {{usedStr}} </div>
        </div>
        <div class="chart-label">
          <div class="legend" :style="{backgroundColor:'#2FA192'}"></div>
          <div class="legend-desc" > {{$t('memory_free_percent')}} {{freeStr}} </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name:"MemoryChart",
  props: {
    used: {
      type: String,
      default: '0'
    },
    frees:{
      type: String,
      default: '100'
    }
  },
  watch:{
    used(){
      //console.log(this.used);
      this.usedStr = this.used + "%";
      //console.log(">>>>> 内存used：%o",this.usedStr);
    },
    frees(){
      //console.log(this.unused);
      this.freeStr = this.frees + "%";
      //console.log(">>>>> 内存free：%o",this.freeStr);
    }
  },
  data(){
    return{
      usedStr:"0%",
      freeStr:"100%"
    }
  }


}
</script>
<style lang="less">
#memory-chart-main{
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  //flex-direction: column;

  .mcm-left{
    width: 20%;
    height: 90%;
    display: flex;
    flex-direction: column;
  }
  .mcm-right{
    width: 75%;
    height: 90%;
    //background-color: #0e3156;
    display: flex;
    flex-direction: column;

    .mcmr-title{
      width: 100%;
      height: 33%;
      font-size: 15px;
      color: #FFFFFF;
      display: flex;
      justify-content: center;
      align-items: center;
      //background-color: #3caf36;
    }

    .mcmr-process{
      width: 100%;
      height: 33%;
      //background-color: #0c0c0c;
      display: flex;
      //justify-content: center;
      align-items: center;

      /*进度条*/
      .progress-bar {
        width: 95%;
        height: 30px;
        background-color: #2FA192;
        border-radius: 10px;
        overflow: hidden;
      }

      .progress {
        height: 100%;
        //background-color: #7fbf7f;
        width: 50%;
        border-radius: 10px;
        background: linear-gradient(to right, #efdac4, #b3934a);
        transition: width 0.5s ease;
        display: flex;
        justify-content: flex-end;
        //justify-content :: center;
        align-items: center;
        flex-direction: row-reverse;
      }
      .progress.active {
        width: 50%;
      }
    }

    .mcmr-bottom{
      width: 100%;
      height: 33%;
      display: flex;
      //background-color: #0000ff;
    }
  }

  /*图例*/
  .chart-label{
    width: 50%;
    height: 100%;
    //border: 0.5px solid #2B333F;
    display: flex;
    align-items: center;
    .legend{
      width: 20px;
      height: 10px;
      background-color: #b3934a;
      border-radius: 2px;
    }
    .legend-desc{
      margin-left: 10px;
      font-size: 12px;
    }
  }

  /* 栏目图标*/
  .mcm-icon{
    width: 50px;
    height: 50px;
    margin-top: 20px;
    margin-left: 20px;
    background-size: 100% 100%;
  }
}

.memory-chart-container{
  margin-top: 20px;
  width: 100%;
  height: 100%;
}

</style>
